﻿#define _CRT_SECURE_NO_WARNINGS 1
#include"Tree.h"
//申请空间
BT* koj(data x)
{
	//申请节点
	BT* tab = (BT*)malloc(sizeof(BT));
	if (tab == NULL)
	{
		perror("malloic");
		exit(1);
	}
	tab->arr = x;
	tab->zuo= tab->you = NULL;

	return tab;
}
void p()
{
	//创建节点
	BT* n1 = koj(1);
	BT* n2 = koj(2);
	BT* n3 = koj(3);
	BT* n4 = koj(4);

	//BT* n5 = koj(5);
	//BT* n6 = koj(6);
	//进行连接
	n1->zuo = n2;
	n1->you = n3;
	n2->zuo = n4;

	//n2->you = n5;
	//n3->zuo = n6;
	
	/*qian(n1);
	printf("\n");*/

	/*zho(n1);
	printf("\n");*/

	//ho(n1);
	//⼆叉树结点个数 
	printf("size:%d \n", BinaryTreeSize(n1));

	 
	//叶子节点个数
	printf("叶子节点：%d\n", BinaryTreeLeafSize(n1));
	//k层节点个数
	printf("k: %d \n", BinaryTreeLevelKSize(n1, 3));

	//⼆叉树的深度/⾼度
	printf("高度:%d \n", BinaryTreeDepth(n1));

	// ⼆叉树查找值为x的结点 
	BT* tab = BinaryTreeFind(n1, 4);
	printf("%s\n", tab == NULL ? "没找到" : "找到了");

	//销毁
	BinaryTreeDestory(&n1);

}



int main()
{
	p();
	return 0;
}